package com.example.controller.shangPinController;

import com.example.utils.UploadUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author:郭
 * @Description: TODO
 * @Date: 2022/12/16 16:12
 * @ClassName UploadController
 */
@RestController
public class UploadController {
    /**
     * @Author: 郭
     * @Date: 2022/12/16 16:13
     * @Param: multipartFile
     * @Return: String
     * 返回图片上传后存储的地址
     */
    @PostMapping("/fileImg/mainImage")
    public String uploadImage(@RequestParam(value = "file")MultipartFile multipartFile){
        if (multipartFile.isEmpty()){
            return "文件有误";
        }
        return UploadUtils.uploadImage(multipartFile);
    }

}
